package com.lb.shopguide.adapter.tag;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

import com.lb.shopguide.R;
import com.lb.shopguide.ui.view.flowlayout.Attribute;
import com.lb.shopguide.ui.view.flowlayout.FlowLayout;
import com.lb.shopguide.ui.view.flowlayout.TagAdapter;

import java.util.List;

/**
 * Created by kang on 2017/9/23.
 */

public class AdapterFlowTagRec extends TagAdapter<String> {
    private TextView tv;
    private LayoutInflater mInflater;
    private Context mContext;

    public AdapterFlowTagRec(Context context, Attribute ab) {
        super(ab);
        mInflater = LayoutInflater.from(context);
        mContext = context;
    }

    @Override
    public View getView(FlowLayout parent, int position, Attribute t) {
        boolean is = false;
        //两个布局,一个是可点击的布局，一个是不可点击的布局
        List<String> st = t.failureAliasName;
        if (st != null) {
            for (int i = 0; i < st.size(); i++) {
                if (st.get(i).equals(t.aliasName.get(position))) {
                    is = true;
                }
            }
        }
        if (!is) {
            tv = (TextView) mInflater.inflate(R.layout.tv_tag_rec, parent, false);
            tv.setText(t.aliasName.get(position));
            if (getPreCheckedList().contains(position)) {
                tv.setTextColor(mContext.getResources().getColor(R.color.rec_red_common));
            }else{
                tv.setTextColor(mContext.getResources().getColor(R.color.rec_color_333333));
            }
        } else {
            tv = (TextView) mInflater.inflate(R.layout.tv_tag_unable, parent, false);
            tv.setText(t.aliasName.get(position));
        }

        return tv;
    }
}
